
package com.meme.editor.level.define;

import java.util.List;
import java.util.Vector;

import com.meme.editor.level.Actor;
import com.meme.editor.property.Property;
import com.meme.editor.property.PropertyGroupSet;

import com.meme.editor.EntityObject;

public class ActorTemplate extends EntityObject
{
	//String mName;
	String mActorType;
	int mZOrder;
	
	List<PropertyDefineBlock> mTemplatePropertyGroupDefines = new Vector<PropertyDefineBlock> ();
	List<AppearanceDefine> mAppearanceDefines    = new Vector<AppearanceDefine> ();
	List<PropertyDefineBlock> mInstancePropertyGroupDefines = new Vector<PropertyDefineBlock> ();
	
	boolean mIsReserved;
	
	public ActorTemplate (String name, String type, int zOrder)
	{
		this (name, type, zOrder, false);
	}
	
	public ActorTemplate (String name, String type, int zOrder, boolean reserved)
	{
		//mName = name;
		super (name);
		mActorType = type;
		mZOrder = zOrder;
	}
	
	public boolean isReserved ()
	{
		return mIsReserved;
	}
	
//	public String getName ()
//	{
//		return mName;
//	}
	
	public String getActorType ()
	{
		return mActorType;
	}
	
	public int getDefaultZOrder ()
	{
		return mZOrder;
	}
	
	public String toString ()
	{
		//return mName;
		return getName ();
	}
	
//	public Actor createActorInsstance ()
//	{
//		Actor actor = new Actor (mName);
//		
//		for (AppearanceDefine appearanceDefine : mAppearanceDefines)
//		{
//			appearanceDefine.createAppearanceInstanceFor (actor);
//		}
//		
//		for (PropertyDefineBlock propertyDefineBlock : mPropertyGroupDefines)
//		{
//			propertyDefineBlock.createPropertyGroupFor (actor);
//		}
//		
//		return actor;
//	}
	
	
	
	// pls assure this template has already been added to a define file before calling this function
	public void addTemplatePropertyDefines (List<PropertyDefineBlock> propertyGroupDefines)
	{
		mTemplatePropertyGroupDefines.addAll (propertyGroupDefines);
		
		for (PropertyDefineBlock propertyDefineBlock : propertyGroupDefines)
		{
			propertyDefineBlock.makePropertyGroupForEntity (this);
		}
	}
	
	public List<PropertyDefineBlock> getTemplatePropertyDefines ()
	{
		return mTemplatePropertyGroupDefines;
	}
	
	
	public void addAppearanceDefines (List<AppearanceDefine> appearanceDefines)
	{
		mAppearanceDefines.addAll (appearanceDefines);
	}
	
	public List<AppearanceDefine> getAppearanceDefines ()
	{
		return mAppearanceDefines;
	}
	
	public void addInstancePropertyDefines (List<PropertyDefineBlock> propertyGroupDefines)
	{
		mInstancePropertyGroupDefines.addAll (propertyGroupDefines);
	}
	
	public List<PropertyDefineBlock> getInstancePropertyDefines ()
	{
		return mInstancePropertyGroupDefines;
	}

	
	public List<Property> getCostomPropertyList ()
	{
		List <Property> propertyList = new Vector <Property> ();
		
		PropertyGroupSet propertyGroupSet = getPublicProperties(); 
		
		for (PropertyDefineBlock propertyDefineBlock : mTemplatePropertyGroupDefines)
		{
			for (PropertyDefine propertyDefine : propertyDefineBlock.getPropertyDefines())
			{
				propertyList.add (propertyGroupSet.getPropertyInGroup(propertyDefineBlock.getName(), propertyDefine.getName()));
			}
		}
		
		return propertyList;
	}
}
